package com.example.design.c.state.demo3;

/**
 * 线程新建状态
 */
public class StateNew extends ThreadAbstractState {
    /**
     * 构造方法初始化状态名称
     */
    public StateNew() {
        this.setStateName("新建");
    }

    @Override
    public boolean start(ThreadContext context) {
        System.out.println("============================");
        System.out.println("新建线程...");

        String stateName = context.getState().getStateName();

        if ("新建".equals(stateName)) {
            context.setState(new StateRunnable());
            context.showState();
            return true;
        }
        System.out.println("非'新建'或者'阻塞'状态无法调用resume方法");
        return false;
    }
}
